from client import IncoreClient 
from fragilityservice import FragilityService
from mappingset import MappingSet
from bridgedamage import BridgeDamage
import pandas as pd

client = IncoreClient()

hazard_type = "earthquake"
hazard_id = "5b902cb273c3371e1236b36b"

bridge_dataset_id = "5a284f2dc7d30d13bc082040"

mapping_id = "5b47bcce337d4a37755e0cb2"

use_hazard_uncertainty = False
use_liquefaction = False

bridge_dmg = BridgeDamage(client)

bridge_dmg.load_remote_input_dataset("bridges", bridge_dataset_id)

fragility_service = FragilityService(client)
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))
bridge_dmg.set_input_dataset("dfr3_mapping_set", mapping_set)

result_name = "bridge_result"

bridge_dmg.set_parameter("result_name", result_name)
bridge_dmg.set_parameter("hazard_type", hazard_type)
bridge_dmg.set_parameter("hazard_id", hazard_id)
bridge_dmg.set_parameter("num_cpu", 4)

bridge_dmg.run_analysis()

result = bridge_dmg.get_output_dataset("result")

df = result.get_dataframe_from_csv()

df.head()